/**
Author ffpan
Date 2010-04-04
Version 1.0
**/
$(document).ready(function(){
	//初始化中介的tips
	initTips($("#agent_name"));
	
	$("#agent_order").bind("change" , function(){
		var opt =$(this).val(); 
		ajaxAgent(opt , 1);
	});
	
	if($("#anextpage")){
		checkpage();
		$("#aprevpage").bind("click" , function(){
			p = parseInt($("#anowpage").val())-1;
			$("#anowpage").val(p);
			$("#showpage").html(p);
			checkpage();
			ajaxAgent($("#agent_order").val() , p);
		});
		
		$("#anextpage").bind("click" , function(){
			p = parseInt($("#anowpage").val())+1;
			$("#anowpage").val(p);
			$("#showpage").html(p);
			checkpage();
			ajaxAgent($("#agent_order").val() , p);
		});
	}
	
	if($("#sbtn")){
		$("#sbtn").bind("click" , function(){
			if($("#skey").val()==$("#skey").attr("tips")){$("#skey").val("");}
			ajaxAgent($("#agent_order").val() , 1 , $("#skey").val());
		});
	}
	
	function checkpage(){
		var nowpage = parseInt($("#anowpage").val());
		var totalpage = parseInt($("#atotalpage").val());
		if(nowpage==1){
			$("#aprevpage").css("visibility" , "hidden");
		}else{
			$("#aprevpage").css("visibility" , "visible");
		}
		if(nowpage==totalpage){
			$("#anextpage").css("visibility" , "hidden");
		}else{
			$("#anextpage").css("visibility" , "visible");
		}
	}
	
	function ajaxAgent(order , page , key , lx){
	    if(key==undefined){key = "";}
		if(lx==undefined){lx=1;}
		$.ajax({
			type:"GET",
			url:"ajax_kuser_order.php",
			data:"order="+order+"&p="+page+"&key="+key+"&lx="+lx,
			success:function(json){
				var str = "";
				var json = eval(json);
				$.each(json, function(k){
					str += "<li><a href='kuser_detail.php?kid="+json[k]["id"]+" target='blank'><img src='_skins/tplimgs/avatar_popular.jpg' width='56' /></a><a href='kuser_detail.php?kid='"+json[k]["id"]+"' target='blank' style='color:#000;text-decoration:underline;'><span>"+json[k]["name"]+"</span></a><span class='grayw'>"+json[k]["lastlogin"]+"</span></li>";
				});
				$("#alistdiv").html(str);
			}
		});
	}






}); 





//
//window.onunload=GUnload;



